package jni;

import java.io.File;
import java.lang.reflect.Field;

public class JniTest {
    static {
        System.setProperty("java.library.path", "/home/web/");
        try {
            Class<?> threadClazz = Class.forName("java.lang.ClassLoader");
            Field method = threadClazz.getDeclaredField("sys_paths");
            method.setAccessible(true);
            Field usr_paths = threadClazz.getDeclaredField("usr_paths");
            usr_paths.setAccessible(true);
            String[] sys_paths2 = (String[])method.get(ClassLoader.class);
            String[] usr_paths2 = (String[])usr_paths.get(ClassLoader.class);
            for (String s : sys_paths2) {
                System.out.println("sys_paths2" + s+ "," +System.mapLibraryName("JniTest"));
            }
            for (String s : usr_paths2) {
                System.out.println("usr_paths2" + s+ ","+System.mapLibraryName("JniTest"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
//        ClassLoader.loadLibrary(fromClass, libname, false)
        System.loadLibrary("JniTest");
    }

    public native void jniHello();

    public static void main(String[] args) {
        JniTest jni = new JniTest();
        jni.jniHello();
    }
}